package ch.zbw.pra.sysventory.domain.visualisation;

import java.util.ArrayList;
import java.util.List;

import ch.zbw.pra.sysventory.domain.model.Printer;

public class VisuControllPrinter extends AVisuControll implements IVisuControll<Printer> {

	private boolean printerName;
	private boolean printerDriverName;
	private boolean printerDriverVersion;

	public VisuControllPrinter() {
		super();
	}

	public boolean isPrinterName() {
		return this.printerName;
	}

	public void setPrinterName(boolean printerName) {
		this.printerName = printerName;
		updateObserver();
	}

	public boolean isPrinterDriverName() {
		return this.printerDriverName;
	}

	public void setPrinterDriverName(boolean printerDriverName) {
		this.printerDriverName = printerDriverName;
		updateObserver();
	}

	public boolean isPrinterDriverVersion() {
		return this.printerDriverVersion;
	}

	public void setPrinterDriverVersion(boolean printerDriverVersion) {
		this.printerDriverVersion = printerDriverVersion;
		updateObserver();
	}

	public void addDataToRow(List<Printer> data, List<List<String>> row) {
		if (isPrinterName()) {
			row.add(makePrinterNameList(data));
		}
		if (isPrinterDriverName()) {
			row.add(makePrinterDriverNameList(data));
		}
		if (isPrinterDriverVersion()) {
			row.add(makePrinterDriverVersionList(data));
		}
	}

	public void addDataToColumn(List<String> data) {
		if (isPrinterName()) {
			data.add("Drucker Name");
		}
		if (isPrinterDriverName()) {
			data.add("Treiber Name");
		}
		if (isPrinterDriverVersion()) {
			data.add("Treiber Version");
		}
	}

	private List<String> makePrinterNameList(List<Printer> printer) {
		List<String> data = new ArrayList<String>();
		for (Printer print : printer) {
			data.add(print.getNamePrinter());
		}
		return data;
	}

	private List<String> makePrinterDriverNameList(List<Printer> printer) {
		List<String> data = new ArrayList<String>();
		for (Printer print : printer) {
			data.add(print.getDriverNamePrinter());
		}
		return data;
	}

	private List<String> makePrinterDriverVersionList(List<Printer> printer) {
		List<String> data = new ArrayList<String>();
		for (Printer print : printer) {
			data.add(print.getDriverVersionPrinter());
		}
		return data;
	}

	public void restoreTo(boolean value) {
		this.printerName = value;
		this.printerDriverName = value;
		this.printerDriverVersion = value;
	}
}
